<div id="sectoralStatisticsPage">
    <div class="post">
        <h2 class="title">Sectoral Statistics</h2>
        <div class="entry">
            <input type="button" value="Add new" onclick="show('#new_sectoral_statistics')"/>
            <?php
         //   if ($this->session->userdata("admin")) {
            ?>
                <input type="button" value="Search" onclick="show('#searchSectoralStatistics')"/>
                <input type="button" value="Clear Search" onclick="clearSearch()"/>
            <?php
         //   }
            ?>
            <div id="ss_result" class="info">
                <?= $message ?>
            </div>
            <script>
                $(function() {
                    $( "#sectdate" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
            </script>
            <script type="text/javascript">
                function searchSectoralStatistics(num){
                    field=document.getElementById("searchSectoralStatisticsForm"+num).field.value;
                    search=document.getElementById("searchSectoralStatisticsForm"+num).search.value;
                    $("#sectoralStatisticsPage").load("<?= base_url(); ?>index.php?/admin_mis/sectoral_statistics/"+field+"/"+search);
                }
                function clearSearch(){
                    $("#sectoralStatisticsPage").load("<?= base_url(); ?>index.php?/admin_mis/sectoral_statistics/");
                }
            </script>
            <div id="new_sectoral_statistics" style="display: none;margin-bottom: 10px;">
                <?php $data['id'] = "sectoral_statistics_form" ?>
                <?= form_open_multipart('mis/saveSectoral_statistic', $data); ?>
                <table>
                    <tr class="darker"><td class="half">Organizational Name</td><td><input type="text" class="wide" name="org_name" value="<?php echo set_value('org_name'); ?>" /></td> </tr>
                    <tr class="lighter"><td class="half">Category</td><td>
                            <select name="category">
                                <?php foreach ($orgs as $type): ?>
                                    <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                </select>
                            </td> </tr>
                        <tr class="darker"><td class="half">Position</td><td><input type="text" class="wide" name="position" value="<?php echo set_value('position'); ?>" /></td> </tr>
                        <tr class="lighter"><td class="half">Date</td><td><input type="text" class="wide" name="info_date" value="<?php echo set_value('info_date'); ?>" id="sectdate" /></td> </tr>
                        <tr class="darker"><td class="half">source of information</td><td><input type="text" class="wide" name="source" value="<?php echo set_value('source'); ?>" /></td> </tr>
                        <tr class="lighter"><td class="half">Contact information</td><td><input type="text" class="wide" name="contact" value="<?php echo set_value('contact'); ?>" /></td> </tr>


                        <tr><td colspan="2" style="text-align: right">
                                <input type="submit" value="Submit" />
                                <input type="button" value="Cancel" onclick="hide('#new_sectoral_statistics')"/>
                            </td></tr>
                    </table>
                    </form>
                </div>
                <div id="searchSectoralStatistics" style="display: none;margin-bottom: 10px;">
                     <form id="searchSectoralStatisticsForm1">

                        <input type="hidden" name="field" value="category"/>
                        <table>
                            <tr class="darker"><td class="half">Search by category</td>
                                <td><select name="search">
                                 <?php foreach ($orgs as $type): ?>
                                    <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                    </select></td>
                            </tr>

                            <tr><td colspan="2" style="text-align: right">
                                    <input type="button" value="Submit" onclick="searchSectoralStatistics(1)" />
                                    <input type="button" value="Cancel" onclick="hide('#searchSectoralStatistics')"/>
                                </td></tr>

                        </table>
                    </form>
                    <form id="searchSectoralStatisticsForm2">
                        <table>
                            <tr class="darker"><td class="half">Select search criteria</td>
                                <td><select name="field">
                                        <option value='all' >All</option>
                                        <option value='org_name' >Organization name</option>
                                        <option value='position' >Position</option>
                                        <option value='source' >Source of information</option>
                                        <option value='contact' >Contact information</option>    
                                        <option value='added_by'> Added by</option>
                                    </select></td>
                                <td><input type="text" name="search" class="wide"  value="<?php echo set_value('added_by'); ?>" /></td>
                            </tr>

                            <tr><td colspan="3" style="text-align: right">
                                    <input type="button" value="Submit" onclick="searchSectoralStatistics(2)" />
                                    <input type="button" value="Cancel" onclick="hide('#searchSectoralStatistics')"/>
                                </td></tr>

                        </table>
                    </form>
                </div>
                <div id="all_sectoral_statistics">
                <?= $tablet ?>
                <?= $pagina ?>
            </div>
        </div>
    </div>
</div>